package cn.iocoder.yudao.module.carbon.dal.mysql.accountboundary;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.carbon.api.accountboundary.dto.AccountBoundaryListReqDTO;
import cn.iocoder.yudao.module.carbon.controller.admin.accountboundary.vo.AccountBoundaryExportReqVO;
import cn.iocoder.yudao.module.carbon.controller.admin.accountboundary.vo.AccountBoundaryPageReqVO;
import cn.iocoder.yudao.module.carbon.dal.dataobject.accountboundary.AccountBoundaryDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 核算边界 Mapper
 *
 * @author StevenShen
 */
@Mapper
public interface AccountBoundaryMapper extends BaseMapperX<AccountBoundaryDO> {

    default PageResult<AccountBoundaryDO> selectPage(AccountBoundaryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AccountBoundaryDO>()
                .eqIfPresent(AccountBoundaryDO::getStandard, reqVO.getStandard())
                .eqIfPresent(AccountBoundaryDO::getClassification, reqVO.getClassification())
                .eqIfPresent(AccountBoundaryDO::getCategory, reqVO.getCategory())
                .eqIfPresent(AccountBoundaryDO::getCategoryDesc, reqVO.getCategoryDesc())
                .orderByAsc(AccountBoundaryDO::getId));
    }

    default List<AccountBoundaryDO> selectList(AccountBoundaryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AccountBoundaryDO>()
                .eqIfPresent(AccountBoundaryDO::getStandard, reqVO.getStandard())
                .eqIfPresent(AccountBoundaryDO::getClassification, reqVO.getClassification())
                .eqIfPresent(AccountBoundaryDO::getCategory, reqVO.getCategory())
                .eqIfPresent(AccountBoundaryDO::getCategoryDesc, reqVO.getCategoryDesc())
                .orderByAsc(AccountBoundaryDO::getId));
    }


    default List<AccountBoundaryDO> selectList(AccountBoundaryListReqDTO reqDTO) {
        return selectList(new LambdaQueryWrapperX<AccountBoundaryDO>()
                .eqIfPresent(AccountBoundaryDO::getStandard, reqDTO.getStandard())
                .eqIfPresent(AccountBoundaryDO::getClassification, reqDTO.getClassification())
                .orderByAsc(AccountBoundaryDO::getId));
    }

    default AccountBoundaryDO selectOneByCategory(String standard, String classification, String category) {
        return selectOne(new LambdaQueryWrapperX<AccountBoundaryDO>()
                .eqIfPresent(AccountBoundaryDO::getStandard, standard)
                .eqIfPresent(AccountBoundaryDO::getClassification, classification)
                .eqIfPresent(AccountBoundaryDO::getCategory, category));
    }
}
